﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Diagnostics;
using JCNT.DAL;
using Pub;
//using JCNT.NoteWeb.Pub;

namespace JCNT.NoteWeb.Web
{
    public partial class Right : System.Web.UI.Page
    {
        CADO ado1 = new CADO();
        C_CMS cms = new C_CMS();
        DataSet ds1 = null;
        string s_sql = "";
        string s_id;


        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["ID"] != null)
                s_id = Request["ID"].ToString();

            if (!IsPostBack)
            {

                Fill_ds();
                //if (Session["login"] != null)
                //{

                //}
                //else
                //{
                //    //跳转到登入页面                
                //    Response.Write("<script>alert('您的登录信息过期，请重新登录！');</script>");
                //    Response.Write("<script>window.opener = null;parent.close();window.open ('login.aspx');</script>");
                //}
            }
        }

        public void Fill_ds()
        {
            if (s_id == null) return;
            Panel1.Visible = true;
            
            s_sql = "select id,tit,con,lab,oth,setDat from wp_note where id = " + s_id;
            ds1 = ado1.sel1(s_sql);
            lab_tit.Text = ds1.Tables[0].Rows[0]["tit"].ToString();
            lab_con.Text = "<xmp>" + ds1.Tables[0].Rows[0]["con"].ToString() + "</xmp>";
            lab_lab.Text = ds1.Tables[0].Rows[0]["lab"].ToString();
            lab_oth.Text = ds1.Tables[0].Rows[0]["oth"].ToString();
            lab_dat.Text = ds1.Tables[0].Rows[0]["setDat"].ToString();
            btn_del.Attributes.Add("onclick", "return confirm(\"你确认要删除吗？\")");
        }

        //编辑
        protected void btn_edt_Click(object sender, EventArgs e)
        {

            Session["Edit_Type"] = 0;
            Response.Redirect("Edit.aspx?id=" + s_id + "&typ=0");
        }

        //添加
        protected void btn_add_Click(object sender, EventArgs e)
        {

            Session["Edit_Type"] = 1;
            Response.Redirect("Edit.aspx?id=" + s_id + "&typ=1");
        }

        //查找
        protected void btn_qry_Click(object sender, EventArgs e)
        {
            Response.Redirect("Query.aspx");
        }

        //删除
        protected void btn_del_Click(object sender, EventArgs e)
        {

            cms.note_Del(s_id);
            Session["nodeID"] = null;
        }
    }
}
